<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <title>个人中心 - 助农购物网站</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="${pageContext.request.contextPath}/logo/favicon.ico">
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .profile-card {
            margin-top: 30px;
            border: 1px solid #dee2e6;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .profile-header {
            background: linear-gradient(135deg, #212529 0%, #495057 100%);
            color: white;
            padding: 30px;
            border-radius: 8px 8px 0 0;
        }
        .profile-body {
            padding: 30px;
        }
        .info-item {
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid #e9ecef;
        }
        .info-item:last-child {
            border-bottom: none;
        }
        .info-label {
            font-weight: bold;
            color: #495057;
            margin-bottom: 5px;
        }
        .info-value {
            color: #6c757d;
        }
        .form-group {
            margin-bottom: 20px;
        }
        .balance-display {
            font-size: 24px;
            font-weight: bold;
            color: #198754;
        }
    </style>
</head>
<body>
    <jsp:include page="common/header.jsp"/>
    
    <div class="container-fluid">
        <div class="row">
            <jsp:include page="common/sidebar.jsp"/>
            
            <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
                <div class="pt-3">
                    <div class="row justify-content-center">
                        <div class="col-md-10">
                            <div class="card profile-card">
                                <div class="profile-header">
                                    <h3><i class="bi bi-person-circle"></i> 个人中心</h3>
                                    <p class="mb-0">欢迎，${admin.realName != null && !empty admin.realName ? admin.realName : admin.username}</p>
                                </div>
                                
                                <div class="profile-body">
                                    <!-- 消息提示 -->
                                    <c:if test="${message != null}">
                                        <div class="alert alert-success alert-dismissible fade show" role="alert">
                                            ${message}
                                            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                                        </div>
                                    </c:if>
                                    
                                    <c:if test="${error != null}">
                                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
                                            ${error}
                                            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                                        </div>
                                    </c:if>
                                    
                                    <!-- 用户信息展示 -->
                                    <div class="mb-4">
                                        <h5 class="mb-3">账户信息</h5>
                                        <div class="info-item">
                                            <div class="info-label">用户名</div>
                                            <div class="info-value">${admin.username}</div>
                                        </div>
                                        <div class="info-item">
                                            <div class="info-label">账户余额</div>
                                            <div class="balance-display">¥<fmt:formatNumber value="${admin.balance != null ? admin.balance : 0}" pattern="#,##0.00"/></div>
                                        </div>
                                        <div class="info-item">
                                            <div class="info-label">注册时间</div>
                                            <div class="info-value">
                                                <fmt:formatDate value="${admin.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
                                            </div>
                                        </div>
                                    </div>
                                    
                                    <!-- 修改个人信息表单 -->
                                    <div class="mt-4">
                                        <h5 class="mb-3">修改个人信息</h5>
                                        <form action="${pageContext.request.contextPath}/admin/user/profile" method="post">
                                            <div class="form-group">
                                                <label for="realName" class="form-label">真实姓名</label>
                                                <input type="text" class="form-control" id="realName" name="realName" 
                                                       value="${admin.realName != null ? admin.realName : ''}" 
                                                       placeholder="请输入真实姓名">
                                            </div>
                                            
                                            <div class="form-group">
                                                <label for="phone" class="form-label">手机号码</label>
                                                <input type="text" class="form-control" id="phone" name="phone" 
                                                       value="${admin.phone != null ? admin.phone : ''}" 
                                                       placeholder="请输入手机号码">
                                            </div>
                                            
                                            <div class="form-group">
                                                <label for="email" class="form-label">电子邮箱</label>
                                                <input type="email" class="form-control" id="email" name="email" 
                                                       value="${admin.email != null ? admin.email : ''}" 
                                                       placeholder="请输入电子邮箱">
                                            </div>
                                            
                                            <div class="form-group mt-4">
                                                <button type="submit" class="btn btn-dark">保存修改</button>
                                                <a href="${pageContext.request.contextPath}/admin/index" class="btn btn-secondary">返回首页</a>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </main>
        </div>
    </div>
    
    <script src="${pageContext.request.contextPath}/js/bootstrap.bundle.min.js"></script>
</body>
</html>



